Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Component services in Component class #20217

Merged

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Apr 23, 2018

Pull Request for Issue #19580.

Summary of Changes

This pr illustrates how I see the component services implemented. Through an interface the component class defines which services it provides. The base ComponentInterface contains now only the getDisptacher function as this is mandatory for every component. Like that we can introduce new services later without a BC break and do not loose any type hinting.

For every service is a trait available to avoid duplicate code amongst the other components. The following code should illustrate how such a component class will look like:

class FooComponent extends Component implements
	MVCFactoryServiceInterface,
	CategoriesServiceInterface,
	AssociationServiceInterface
{
	use MVCFactoryServiceTrait;
	use CategoriesServiceTrait;
	use AssociationServiceTrait;
}

Additionally the interface BootableExtensionInterface is added where a component class can load its internal class loader or register HTML services in a boot function:

public function boot(ContainerInterface $container)
{
	require_once 'vendor/autoload.php';

	$this->getRegistry()->register('fooicon', new Icon($container->get(SiteApplication::class)));
}

Testing Instructions

  • Create an article
  • Create a custom fields for the article
  • Open the article in the front end

Expected result

All is working as expected.

Actual result

All is working as expected.

Documentation Changes Required

Needs a bigger update on docs.

laoneo and others added 30 commits March 5, 2018 19:07
…ce/helper

# Conflicts:
#	libraries/src/Extension/Component.php
…ce/helper

# Conflicts:
#	administrator/components/com_content/services/provider.php
#	libraries/src/Extension/Component.php
#	libraries/src/Extension/ComponentInterface.php
#	libraries/src/Extension/LegacyComponent.php
#	libraries/src/Extension/Service/Provider/Component.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants